﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AllInOne.Pages
{
    /// <summary>
    /// VinInputPage.xaml 的交互逻辑
    /// </summary>
    public partial class VinInputPage : Page
    {

        public VinInputPage()
        {
            InitializeComponent();
        }

        private MainWindow parent;


        public VinInputPage(MainWindow parent)
        {
            InitializeComponent();
            this.parent = parent;
        }

        public void InitPage()
        {
            this.txtVin.Text = "";
            this.parent.PlaySound(Properties.Resources.male_input_vin_code, Properties.Resources.female_input_vin_code);

        }

        private void BtnService_MouseUp(object sender, MouseButtonEventArgs e)
        {

            string sjhm = txtVin.Text;
            if (sjhm != null && sjhm.Length < 6)
            {
                TextBlock btn = (TextBlock)sender;
                string key = btn.Text;
                txtVin.Text = sjhm + key;
            }
        }

        private void BtnClear_MouseUp(object sender, MouseButtonEventArgs e)
        {
            txtVin.Text = "";


        }

        private void BtnBackspace_MouseUp(object sender, MouseButtonEventArgs e)
        {
            string sjhm = txtVin.Text;
            if (sjhm != null && sjhm.Length > 0)
            {
                txtVin.Text = sjhm.Substring(0, sjhm.Length - 1);
            }
        }

        private void BtnSubmit_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (verifyVin())
            {
                this.parent.SetVinCode(this.txtVin.Text);
            }
        }

        private bool verifyVin()
        {
            return true;
        }

        private void BtnBackToIndex_MouseUp(object sender, MouseButtonEventArgs e)
        {
            this.parent.ResetIndex();
        }

        private void BtnCancel_MouseUp(object sender, MouseButtonEventArgs e)
        {
            this.parent.BackToInputCarNumber();
        }
    }
}
